/*
 * License GNU LGPL
 * Copyright (C) 2012 Amrullah <amrullah@panemu.com>.
 */
package com.abc.cheque.ui.form;


import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

import com.abc.cheque.control.LookupField;
import com.abc.cheque.control.LookupFieldController;





/**
 *
 * @author Amrullah <amrullah@panemu.com>
 */
public class LookupControl<T> extends BaseControl<T, LookupField<T>> {
    private LookupField<T> lookupField;
    private StringProperty nestedPropertyName = new SimpleStringProperty();
    
    public LookupControl() {
        super(new LookupField());
        lookupField = getInputComponent();
        lookupField.propertNameProperty().bind(nestedPropertyName);
    }

    public LookupFieldController<T> getController() {
        return lookupField.getController();
    }

    public void setController(LookupFieldController<T> controller) {
        lookupField.setController(controller);
    }
    

    @Override
    public void setValue(T value) {
        lookupField.setValue(value);
    }

    @Override
    protected void bindValuePropertyWithControl(LookupField<T> inputControl) {
        value.bind(inputControl.valueProperty());
    }

    public String getNestedPropertyName() {
        return nestedPropertyName.get();
    }

    public void setLookupPropertyName(String nestedPropertyName) {
        this.nestedPropertyName.set(nestedPropertyName);
    }
    
}
